package net.dreamlu.config;

import net.bull.javamelody.MonitoringFilter;
import net.bull.javamelody.SessionListener;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: TEST
 * @Date: 2018/6/10 22:11
 * @Description: JAVAMELODY监控配置
 */
@Configuration
public class JavamelodyConfiguration {

	@Bean
	public FilterRegistrationBean monitorFilter() {
		FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new MonitoringFilter());
		filterRegistrationBean.addUrlPatterns("/*");
		return filterRegistrationBean;
	}

	@Bean
	public ServletListenerRegistrationBean sessionListener() {
		ServletListenerRegistrationBean servletListenerRegistrationBean = new ServletListenerRegistrationBean();
		servletListenerRegistrationBean.setListener(new SessionListener());
		return servletListenerRegistrationBean;
	}

}
